package mianxiangduixianganlie;

import java.util.ArrayList;
import java.util.Scanner;

//汽车类（父类）
public class Cars {
    ArrayList<Yzcl> yzcls = new ArrayList<>();
    ArrayList<Limousine> limousines = new ArrayList<>();
    ArrayList<Passengercar> passengercars = new ArrayList<>();


    public Cars() {

    }

    public ArrayList<Yzcl> getYzcls() {
        return yzcls;
    }

    public ArrayList<Limousine> getLimousines() {
        return limousines;
    }

    public ArrayList<Passengercar> getPassengercars() {
        return passengercars;
    }

    public Cars(ArrayList<Limousine> limousines, ArrayList<Passengercar> passengercars,ArrayList<Yzcl> yzcls) {
        this.limousines = limousines;
        this.passengercars = passengercars;
        this.yzcls = yzcls;
    }
//查看车辆情况
    public void show() {
        if (limousines.size() == 0){
            System.out.println("没有车辆");
        }else {
            for (int i = 0; i < limousines.size(); i++) {
                if (limousines.get(i).isZt() == true) {
                    System.out.println("轿车 " + limousines.get(i).getBrand() + ",车牌" + limousines.get(i).getLpnumber() + "," + limousines.get(i).getSeating() + "座," + "日租金￥" + limousines.get(i).getDailyrent() + "元" + "当前可租");
                } else {
                    System.out.println("轿车 " + limousines.get(i).getBrand() + ",车牌" + limousines.get(i).getLpnumber() + "," + limousines.get(i).getSeating() + "座," + "日租金￥" + limousines.get(i).getDailyrent() + "元" + "当前不可租");
                }
            }
            for (int i = 0; i < passengercars.size(); i++) {
                if (passengercars.get(i).isZt() == true) {
                    System.out.println("轿车 " + passengercars.get(i).getBrand() + ",车牌" + passengercars.get(i).getLpnumber() + "," + passengercars.get(i).getSeating() + "座," + "日租金￥" + passengercars.get(i).getDailyrent() + "元" + "当前可租");
                } else {
                    System.out.println("轿车 " + passengercars.get(i).getBrand() + ",车牌" + passengercars.get(i).getLpnumber() + "," + passengercars.get(i).getSeating() + "座," + "日租金￥" + passengercars.get(i).getDailyrent() + "元" + "当前不可租");
                }
            }
        }
    }
    //报废轿车
    public void baofei(){
        Scanner in = new Scanner(System.in);
        System.out.println("请输入要报废车辆车牌号");
        String cph = in.next();
        for (int i = 0; i < limousines.size(); i++) {
            if (limousines.get(i).getLpnumber().equals(cph)){
                limousines.remove(limousines.get(i));
                System.out.println("车辆报废成功");
            }
        }
        }
        //报废客车
    public void baofei1(){
        Scanner in = new Scanner(System.in);
        System.out.println("请输入要报废车辆车牌号");
        String cph = in.next();
        for (int i = 0; i < passengercars.size(); i++) {
            if (passengercars.get(i).getLpnumber().equals(cph)){
                passengercars.remove(passengercars.get(i));
                System.out.println("车辆报废成功");
            }
        }
    }
//添加轿车
    public boolean add(Limousine limousine) {
        return limousines.add(limousine);
    }
//添加客车
    public boolean add1(Passengercar passengercar) {
        return passengercars.add(passengercar);
    }
//租赁轿车
    public void zulin(Limousine limousine) {
        Scanner in = new Scanner(System.in);
        for (int i = 0; i < limousines.size(); i++) {
            if (limousines.isEmpty()) {
                System.out.println("当前没有车辆");
            } else {
                System.out.println("现有车辆如下：");
                for (int j = 0; j < 2; j++) {
                    if (limousine.isZt() == true) {
                        System.out.println("轿车 " + limousines.get(i).getBrand() + ",车牌" + limousines.get(i).getLpnumber() + "," + limousines.get(i).getSeating() + "座," + "日租金￥" + limousines.get(i).getDailyrent() + "元" + "当前可租");
                        System.out.print("请选择要租赁的车辆,请输入车牌号：");
                        String cph = in.next();
                        if (limousine.getLpnumber().equals(cph)) {
                            System.out.println("您租赁的车型是" + limousine.getBrand() + ",车牌号为" + cph + "," + limousine.getSeating() + "座");
                            System.out.print("请输入租赁的天数：");
                            int ts = in.nextInt();
                            double sum = ts * limousine.getDailyrent();
                            System.out.println("请支付" + sum + "元");
                            System.out.println("用车愉快！");
                            limousine.setZt(false);
                            break;
                        } else if (!limousine.getLpnumber().equals(cph) || limousine.getLpnumber() == null) {
                            System.out.println("您输入的车牌号不存在");
                        }
                    } else {
                        System.out.println("轿车 " + limousines.get(i).getBrand() + ",车牌" + limousines.get(i).getLpnumber() + "," + limousines.get(i).getSeating() + "座," + "日租金￥" + limousines.get(i).getDailyrent() + "元" + "当前不可租");
                        break;
                    }
                }
            }
        }
    }
    //租赁客车
    public void zulin1(Passengercar passengercar) {
        Scanner in = new Scanner(System.in);
        for (int i = 0; i < passengercars.size(); i++) {
            if (passengercars.isEmpty()) {
                System.out.println("当前没有车辆");
            } else {
                System.out.println("现有车辆如下：");
                for (int j = 0; j < 2; j++) {
                    if (passengercar.isZt() == true) {
                        System.out.println("轿车 " + passengercars.get(i).getBrand() + ",车牌" + passengercars.get(i).getLpnumber() + "," + passengercars.get(i).getSeating() + "座," + "日租金￥" + passengercars.get(i).getDailyrent() + "元" + "当前可租");
                        System.out.print("请选择要租赁的车辆,请输入车牌号：");
                        String cph = in.next();
                        if (passengercar.getLpnumber().equals(cph)) {
                            System.out.println("您租赁的车型是" + passengercar.getBrand() + ",车牌号为" + cph + "," + passengercar.getSeating() + "座");
                            System.out.print("请输入租赁的天数：");
                            int ts = in.nextInt();
                            double sum = ts * passengercar.getDailyrent();
                            System.out.println("请支付" + sum + "元");
                            System.out.println("用车愉快！");
                            passengercar.setZt(false);
                            break;
                        } else if (!passengercar.getLpnumber().equals(cph) || passengercar.getLpnumber() == null) {
                            System.out.println("您输入的车牌号不存在");
                        }
                    } else {
                        System.out.println("轿车 " + passengercars.get(i).getBrand() + ",车牌" + passengercars.get(i).getLpnumber() + "," + passengercars.get(i).getSeating() + "座," + "日租金￥" + passengercars.get(i).getDailyrent() + "元" + "当前不可租");
                        break;
                    }
                }
            }
        }
    }
    //还轿车
    public void huanche() {
        System.out.println("请输入您要还车的车牌号：");
        Scanner in = new Scanner(System.in);
        String cph = in.next();
        for (int i = 0; i < limousines.size(); i++) {
            if (limousines.get(i).getLpnumber().equals(cph)){
                if (limousines.get(i).isZt()==false){
                    limousines.get(i).setZt(true);
                    System.out.println("还车成功");
                }
            }else {
                System.out.println("您输入的车牌号不存在");
            }

        }
    }
    //还客车
    public void huanche1() {
        System.out.println("请输入您要还车的车牌号：");
        Scanner in = new Scanner(System.in);
        String cph = in.next();
        for (int i = 0; i < passengercars.size(); i++) {
            if (passengercars.get(i).getLpnumber().equals(cph)){
                if (passengercars.get(i).isZt()==false){
                    passengercars.get(i).setZt(true);
                    System.out.println("还车成功");
                }
            }else {
                System.out.println("您输入的车牌号不存在");
            }

        }
    }
}

